﻿CREATE VIEW [dbo].[vw_mysheet]
AS
SELECT top 1000000 dbo.Repairs.WordOrderId,
          dbo.Repairs.CompId,
          dbo.Article.TroubleDesc,
          a.fullName AS repemp,
          a.userId as repId,
          b.fullName AS applyemp,
          b.userId as applyId,
          c.fullName AS whoempname,
          CONVERT (VARCHAR (100), dbo.Repairs.ApplyTime, 20) AS applytime,
          dbo.Repairs.Phone,
          replace(dbo.Department.fullname,N'中原集团/南京中原/三级市场/','') as deptname,
          dbo.MaintainStatus.StatusDesc,
         [repairs].SolutionDesc,
          [repairs].troubledesc as troubledesc2,
          [repairs].evaluate,
          repairs.email,
          a.email as fixeremail
     FROM Repairs
          inner join Article on dbo.Repairs.ArticleId = dbo.Article.ArticleId
          left JOIN [User] a ON a.id = dbo.Repairs.RepEmp
          INNER JOIN [User] b ON b.id = dbo.Repairs.ApplyEmp
         left JOIN [User] c ON c.id = dbo.Repairs.WhoEmpName
          INNER JOIN MaintainStatus
             ON dbo.MaintainStatus.StatusId = dbo.Repairs.StatusId
          INNER JOIN Department
             ON dbo.Department.DeptId = dbo.Repairs.ApplyAddres
             order by dbo.Repairs.LastUpdateTime desc